import Axios from 'axios'
import { Connect } from './tools'
let qs = require('qs')
Axios.defaults.withCredentials = true
var baseUrl = Connect.newbaseURL
//\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/普通form表单提交=>post\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\//\/\/\/\/\/\/\/\/\///
let formPost = Axios.create({
	baseUrl,
	headers: {
		'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
	},
	method: 'POST',
})
let showResult = re => {
	// console.log(re)
}
formPost.interceptors.request.use(config => {
	if (sessionStorage.getItem('accessToken')) {
		config.headers.Authorization = sessionStorage.getItem('accessToken')
	} else {
		_this.$message.error('网络出错，请重新登录')
		_this.$router.push('/')
	}
	return config
})
let fpost = (link, seting) => {
	let s = qs.stringify(seting)
	showResult(s)
	return formPost.post(link, s)
}
//\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/普通form表单提交=>post\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\//\/\/\/\/\/\/\/\/\///

//\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/普通json字符串提交=>post\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\//\/\/\/\/\/\/\/\/\///
let jPost = Axios.create({
	baseUrl,
	headers: {
		'Content-Type': 'application/json;charset=UTF-8',
	},
	method: 'POST',
})
jPost.interceptors.request.use(config => {
	if (sessionStorage.getItem('accessToken')) {
		config.headers.Authorization = sessionStorage.getItem('accessToken')
	} else {
		_this.$message.error('网络出错，请重新登录')
		_this.$router.push('/')
	}
	return config
})
let jpost = (link, seting) => {
	// let s = qs.stringify(seting)
	showResult(seting)
	return jPost.post(link, seting)
}
//\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/普通json字符串提交=>post\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\//\/\/\/\/\/\/\/\/\///
//\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/podt提交\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\//\/\/\/\/\/\/\/\/\///

let Jget = Axios.create({
	baseUrl,
	headers: {
		'Content-Type': 'application/json;charset=UTF-8',
	},
	method: 'GET',
})
Jget.interceptors.request.use(config => {
	if (sessionStorage.getItem('accessToken')) {
		config.headers.Authorization = sessionStorage.getItem('accessToken')
	} else {
		_this.$message.error('网络出错，请重新登录')
		_this.$router.push('/')
	}
	return config
})
let jget = (link, seting) => {
	// let s = qs.stringify(seting)
	showResult(seting)
	return Jget.get(link, seting)
}
//\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/普通json字符串提交=>get\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\//\/\/\/\/\/\/\/\/\///
//\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/get提交\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\//\/\/\/\/\/\/\/\/\///
let Fget = Axios.create({
	baseUrl,
	header: {
		'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
	},
	method: 'get',
})
Fget.interceptors.request.use(config => {
	if (sessionStorage.getItem('accessToken')) {
		config.headers.Authorization = sessionStorage.getItem('accessToken')
	} else {
		_this.$message.error('网络出错，请重新登录')
		_this.$router.push('/')
	}
	return config
})
let fget = (link, seting) => {
	let s = qs.stringify(seting)
	showResult(s)
	return Fget.get(link, s)
}

let Murl = {
	getTJList : baseUrl + '/getTJList', //交易币类型

}
///\/\/\/\/\/\/\/\/\/\/\//\/\/\/\/\/\/\/\//\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
export { fpost, jpost, jget, fget, Murl }
